<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>限额投放设置表 管理</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<form id="capPayLimCfg_form">
    <div class="fieldset1 tabel_col tabel_col_1 clearFix">

        <div class="fieldBox col_100">
            <div class="label">类型</div>
            <div class="field">
                <input name="cfgTypCd" id="cfgTypCd" data-value="${capPayLimCfgVO.cfgTypCd}" placeholder="请选择"
                       ltype="combobox" validate="{required:true}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_100">
            <div class="label">资管机构名称</div>
            <div class="field">
                <input name="mgtOrgNm" id="mgtOrgNm" type="text" class="ui-textbox" value="${capPayLimCfgVO.mgtOrgNm}"
                       validate="{required:true,maxlength:100}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_100">
            <div class="label">生效时间</div>
            <div class="field">
                <input name="startTm" id="startTm" type="text" class="ui-datepicker" value="${capPayLimCfgVO.startTm}"
                       validate="{required:true}" ligerui="{showTime:true}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_100">
            <div class="label">启用额度</div>
            <div class="field">
                <input name="ttlAmt" id="ttlAmt" type="text" class="ui-textbox" value="${capPayLimCfgVO.ttlAmt}"
                       validate="{required:true,number:true}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <input name="limStsCd" id="limStsCd" type="text" value="1" style="display: none">
        <input name="mgtOrgId" id="mgtOrgId" type="text" value="${capPayLimCfgVO.mgtOrgId}" style="display: none">
        <input name="buOrgCd" id="buOrgCd" type="text" value="00000001" style="display: none">
    </div>
    <div class="btnsBox">
        <span id="saveCapPayLimCfg_Btn" class="sq-button sq-button-round l-dialog-btn-ok">保存</span>
        <input type="reset" id="resetBtn" class="l-button l-button-reset Hide">
    </div>
</form>
<script>
    var form = null;
    $(function () {
        var capPayLimCfgId = "${capPayLimCfgVO.id}";//主键ID

        var refPrjDialog = null;
        $("#mgtOrgNm").focus(function (event) {
            if (liger.get("cfgTypCd").getValue() == "1") {
                return;
            }
            refPrjDialog = $.ligerDialog.SQopen({
                url: "<%=path%>/capital/capPayLimCfg/toChooseListPage.do",
                width: 800,
                height: 400,
                title: "选择资管机构"
            });
        });

        form = $("#capPayLimCfg_form").ligerForm({
            validate: true
        });
        $("#cfgTypCd").ligerComboBox({
            valueField: 'key',
            textField: 'value',
            onChangeValue: function (value) {
                var cfgTypCd = liger.get("cfgTypCd").getValue();
                if (cfgTypCd == "1") {
                    liger.get("mgtOrgNm").setDisabled(true);
                    form.setFieldValidate("mgtOrgNm", {required: false});
                } else {
                    liger.get("mgtOrgNm").setEnabled(true);
                    form.setFieldValidate("mgtOrgNm", {required: true});
                }
            }
        });
        liger.get("cfgTypCd").setData(${cfgTypCdList});
        liger.get("cfgTypCd").updateStyle();

        /*保存*/
        $("#saveCapPayLimCfg_Btn").click(function (event) {
            var form = liger.get("capPayLimCfg_form");
            if (!form.valid()) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
                return false; //验证不通过，不执行以下代码
            }
            var data = form.getData();
            data['startTm'] = $("#startTm").val();
            $.ligerDialog.hide();
            var _url;
            if (capPayLimCfgId == '') {//新增
                _url = '<%=path%>/capital/capPayLimCfg/add.do';
            } else {//修改
                _url = '<%=path%>/capital/capPayLimCfg/modify.do?id=' + capPayLimCfgId;
            }
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: data,
                url: _url,
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        parent.$("#clearBtn").click();
                        parent.$("#searchBtn").click();
                        frameElement.dialog.close();

                        //$("#resetBtn").click();
                        //回调刷新列表
                        //var callback=frameElement.W2W.callback;
                        //Remove_navTab();
                        //callback();
                    } else {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        });
    });
</script>
</body>
</html>
